<?php
class Attendee_list extends CI_Controller{
	public function __construct(){
		parent::__construct();
		if(!isset($_SESSION)){session_start();}
		$this->load->model('attendee_model');
	}
	
	public function index(){
		$data['title'] = 'Attendee List';
		$this->load->view('templates/header',$data);
		$this->load->view('templates/footer');
	}
	
	public function add_attendee(){
		$this->load->helper('form');
		$this->load->library('form_validation');
	
		$data['title'] = 'Register';
	
		$this->form_validation->set_rules('username', 'Username', 'required');
		$this->form_validation->set_rules('password', 'Password', 'required');
		$this->form_validation->set_rules('field', 'Field', 'required');
	
		if ($this->form_validation->run() === FALSE && !isset($_SESSION['user_id']))
		{
			$this->load->view('templates/header', $data);
			$this->load->view('registerationForms/attendee_registeration');
			$this->load->view('templates/footer');
	
		}
		else
		{
			if(!isset($_SESSION['user_id'])){
				$this->attendee_model->create_attendee();
			}
			
			$data['title'] = 'Login';
			$this->load->view('templates/header', $data);
			$this->load->view('pages/home');
			$this->load->view('templates/footer');
		}
	}
/*
	public function update_attendee(){
	}
	
	public function delete_attendee(){
	}
	
	public function show_all_attendees($seminar_id){
	}
	*/
	public function view_dashboard($user_id){
		if(isset($_SESSION['username']) && $_SESSION['user_id'] == $user_id){
			$data['title'] = 'Dashboard';
			$this->load->view('templates/header', $data);
			$this->load->view('attendee/attendee_dashboard', $data);
			$this->load->view('templates/footer');
		}
		else if(!isset($_SESSION['username'])){
			$data['title'] = 'Please login to continue';
			$this->load->view('templates/header', $data);
			$this->load->view('pages/home', $data);
			$this->load->view('templates/footer');
		}
		else{
			$data['title'] = 'Unauthorized Access';
			$this->load->view('templates/header', $data);
			$this->load->view('pages/no_access');
			$this->load->view('templates/footer');
		}
	}
}
?>